package com.applink.sell_proof.broadcast_receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.util.Log;
import android.widget.Toast;

import com.applink.sell_proof.EMarketing;
import com.applink.sell_proof.util.Utility;

public class NetworkConnectivityReceiver extends BroadcastReceiver {

	public static boolean checkDataSync = false;

	@Override
	public void onReceive(Context context, Intent intent) {

		boolean lostconnection = intent.getBooleanExtra(
				ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
		if (lostconnection) {
			EMarketing.setOnline(false);
			Toast.makeText(context, "no network", Toast.LENGTH_LONG).show();
		} else {
			EMarketing.setOnline(true);
			if (checkDataSync == true) {
				Utility.SyncData();
			}
			Log.e("NetworkConnectivityReceiver", "network avaible");
		}
	}
}
